package com.hngy.xpq.sjxuiautomator;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    EditText one, two, three, test;
    Button tj, qk;
    TextView jg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
        onClick();
    }

    private void onClick() {
        tj.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String[] strings = {one.getText().toString(), two.getText().toString(), three.getText().toString()};
                float[] a = sjx.strings_int(strings);
                Log.w("测试用例", test.getText().toString());
                sjx.result(jg, Integer.valueOf((int) a[3]));
                if (sjx.result(jg, Integer.valueOf((int) a[3]))) {
                    sjx.algorithm(jg, a);
                }
                Log.w("测试结果", jg.getText().toString());
            }
        });
        qk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                one.setText("");
                two.setText("");
                three.setText("");
                test.setText("");
                jg.setText("");
            }
        });
    }

    private void init() {
        one = findViewById(R.id.one);
        two = findViewById(R.id.two);
        three = findViewById(R.id.three);
        test = findViewById(R.id.test);
        tj = findViewById(R.id.tj);
        jg = findViewById(R.id.jg);
        qk = findViewById(R.id.qk);
    }
}